package org.bees.cms.web.function;

import org.apache.struts2.ServletActionContext;
import org.bees.cms.web.util.velocity.Configuration;

public abstract class Functions {
	private static final String PREFIX = ServletActionContext.getServletContext().getContextPath();
	private static final String SUFFIX = Configuration.getProperty("action.suffix");

	public static String url(String namespace, String action, String method, String parameters) {
		StringBuilder url = new StringBuilder();
		url.append(PREFIX).append(namespace).append("/").append(action);
		url.append(method.equals("") ? "" : "!" + method);
		url.append(".").append(SUFFIX);
		url.append(parameters.equals("") ? "" : "?" + parameters);
		return url.toString();
	}

}
